package cn.net.lwj.moredb.service.impl;

import cn.net.lwj.common.model.JsonResult;
import cn.net.lwj.common.model.kingbase.XtptTUser;
import cn.net.lwj.common.model.mysql.XtptTUserMysql;
import cn.net.lwj.moredb.mapper.kingbase.TUserMapper;
import cn.net.lwj.moredb.mapper.kingbase.XtptTUserMapper;
import cn.net.lwj.moredb.mapper.mysql.TreeMapper;
import cn.net.lwj.moredb.mapper.mysql.XtptTUserMysqlMapper;
import cn.net.lwj.moredb.service.SjtbService;
import cn.net.lwj.moredb.service.TestService;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import lombok.extern.java.Log;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Log
@Service
public class SjtbServiceImpl implements SjtbService {

    @Resource
    private XtptTUserMysqlMapper xtptTUserMysqlMapper;

    @Resource
    private XtptTUserMapper xtptTUserMapper;

    @Override
    public JsonResult sjtb() {
        //List<TUser> tUsers = userMapper.selectAll();
        //System.out.println(tUsers);
        //
        //List<Map<String, Object>> qgfyTree = treeMapper.getQgfyTree("114");
        //qgfyTree.forEach(System.out::println);
        //xtpt_t_user表字段在kingbase有level这个关键字,不共用实体
        //XtptTUserMysql u = xtptTUserMysqlMapper.selectByPrimaryKey(1);
        //XtptTUser u1 = new XtptTUser();
        //BeanUtils.copyProperties(u, u1);
        //xtptTUserMapper.insert(u1);
        List<XtptTUserMysql> xtptTUserMysqls = xtptTUserMysqlMapper.selectAll();
        for (XtptTUserMysql user : xtptTUserMysqls) {
            XtptTUser user1 = new XtptTUser();
            BeanUtils.copyProperties(user, user1);
            xtptTUserMapper.insert(user1);
            System.out.println("插入" + user.getUserId() + "--" + user.getUsername() + "成功!");
        }
        return JsonResult.responseSuccess("success", "");


    }
}
